#include"TcpServer.hpp"
#include<memory>
#include<string>
#include"Agreement.hpp"
#include"Prase.hpp"
#include"NetCalor.hpp"




void UseOfServer(char* ch[])
{
    LOG(LogLevel::INFO) << "Useage: " << ch[0] << " port" << "\r\n";
}


int main(int argc,char* argv[])
{
    EnableScreen();
    if(argc != 2)
    {
        UseOfServer(argv);
        exit(1);
    }

    
    Calor _calor;

    PraseMessage _prase([&_calor](Demd _demand)->Result{
        return _calor.calor(_demand);
    });

    std::unique_ptr<TcpServer> _server = std::make_unique<TcpServer>(std::stoi(argv[1]),[&_prase](std::string& _buffer)->std::string{
        return _prase.Prase(_buffer);
    });
    _server->Init();
    _server->Start();
    return 0;
}